from django.contrib import admin
from .models import *


# Register your models here.
class ROOMAdmin(admin.ModelAdmin):
    list_display = ['btitle','s_local','s_ltext']
    search_fields = ['btitle','s_local','s_ltext']
    list_per_page = 10


class CABINETAdmin(admin.ModelAdmin):
    list_display = ['btitle', 's_ltext']
    search_fields = ['btitle', 's_ltext']
    list_per_page = 20

class DEVICETYPEAdmin(admin.ModelAdmin):
    list_display = ['btitle', 's_ltext']
    search_fields = ['btitle', 's_ltext']
    list_per_page = 20

class SERVERSAdmin(admin.ModelAdmin):
    list_display = ['S_name', 'S_type', 'S_id', 'S_cab', 'S_ip', 'S_bottom', 'S_top','S_color', 'S_des', 'S_state']
    search_fields = ['S_name','S_type__btitle__icontains', 'S_id__btitle__icontains', 'S_cab__btitle__icontains', 'S_ip', 'S_bottom', 'S_top','S_color', 'S_des']
    list_per_page = 50
    autocomplete_fields = ['S_cab']
    # 下拉框变成单选框 HORIZONTAL为横向
    # radio_fields = {'S_type': admin.HORIZONTAL}


admin.site.register(ROOM,ROOMAdmin)
admin.site.register(CABINET,CABINETAdmin)
admin.site.register(DEVICETYPE,DEVICETYPEAdmin)
admin.site.register(SERVERS,SERVERSAdmin)
